cmake_minimum_required(VERSION 3.5)
project(ftr3_driver)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# 寻找依赖包
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(can_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)

# 声明消息文件
set(msg_files
  "msg/Ftr3Data.msg"
  "msg/Ftr3Status.msg"
)

# 生成消息
rosidl_generate_interfaces(${PROJECT_NAME}
  ${msg_files}
  DEPENDENCIES std_msgs
)

# 包含头文件目录
include_directories(
  include
)

# 创建驱动节点可执行文件
add_executable(ftr3_node
  src/main.cpp
  src/ftr3_driver.cpp
)

# 设置依赖
ament_target_dependencies(ftr3_node
  rclcpp
  std_msgs
  can_msgs
)

# 链接消息库
rosidl_target_interfaces(ftr3_node
  ${PROJECT_NAME} "rosidl_typesupport_cpp"
)

# 安装可执行文件
install(TARGETS
  ftr3_node
  DESTINATION lib/${PROJECT_NAME}
)

# 安装头文件
install(DIRECTORY
  include/${PROJECT_NAME}/
  DESTINATION include/${PROJECT_NAME}
)

# 安装配置文件
install(DIRECTORY
  launch
  config
  DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
